package org.example.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.example.entity.Dept;
import org.example.mapper.DeptMapper;
import org.example.pojo.Result;
import org.example.service.IDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DeptServiceImpl extends ServiceImpl<DeptMapper,Dept> implements IDeptService {

    @Override
    public PageInfo<Dept> listByPage(Integer page, Integer limit,String searchDeptName) {
        LambdaQueryWrapper<Dept> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        //查询删除标志为0的部门
        lambdaQueryWrapper.eq(Dept::getDeleteFlag,"0");

        if(searchDeptName != null){
            lambdaQueryWrapper.like(Dept::getDeptName,searchDeptName);
        }
        PageHelper.startPage(page,limit);
        List<Dept> deptList = this.list(lambdaQueryWrapper);
        PageInfo<Dept> pageInfo = new PageInfo<>(deptList);
        return pageInfo;
    }
}
